Add generic environment-creation utilities (PEP 723 PR 5a/16)#1651
Open
StellaHuang95 wants to merge 3 commits into
Open
Add generic environment-creation utilities (PEP 723 PR 5a/16)#1651StellaHuang95 wants to merge 3 commits into
StellaHuang95 wants to merge 3 commits into
Conversation
StellaHuang95
marked this pull request as ready for review
July 23, 2026 22:21
StellaHuang95
force-pushed
the
pep723-pr5-create-happy-path
branch
from
July 23, 2026 23:06
b1e9b95 to
f005e16
Compare
StellaHuang95
marked this pull request as draft
July 23, 2026 23:09
StellaHuang95
marked this pull request as ready for review
July 23, 2026 23:14
StellaHuang95
force-pushed
the
pep723-pr5-create-happy-path
branch
from
July 23, 2026 23:30
f005e16 to
d36561b
Compare
This was referenced Jul 23, 2026
StellaHuang95
marked this pull request as draft
July 23, 2026 23:34
StellaHuang95
marked this pull request as ready for review
July 23, 2026 23:35
edvilme
reviewed
Jul 23, 2026
edvilme
reviewed
Jul 24, 2026
StellaHuang95
force-pushed
the
pep723-pr5-create-happy-path
branch
from
July 24, 2026 00:13
d36561b to
104166d
Compare
Cross-process file lock, venv Python-path helper, cancellation-safe process runner, and createWithProgress tracking options that inline-script environment creation builds on. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 39dcc6a3-0fbd-4f36-9d0f-68677de49c27
StellaHuang95
force-pushed
the
pep723-pr5-create-happy-path
branch
from
July 24, 2026 17:28
0706167 to
e78bda6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Roadmap context
This is the first slice of PR 5 of 16 in the PEP 723 inline-script roadmap. The full plan lives in #1602.
meta.jsonsidecarrequires-pythonto interpreter selectionInlineScriptEnvManagerskeletoncreate()happy path (manager + wiring)create()uv-install fallbackget,set, and MementoWhy this PR
PR 5c implements
InlineScriptEnvManager.create(). Before touching the manager, this PR lands the generic, reusable primitives it relies on — a cross-process file lock, a venv Python-path helper, a cancellation-hardened process runner, and two smallcreateWithProgressoptions. None of this code is inline-script-specific, so it is reviewed on its own.What this PR adds
Cross-process file lock (
src/common/lockfile.apis.ts, new):acquireFileLockuses an atomicmkdirof a<path>.lockdirectory plus a per-owner marker file, returningAcquiredFileLock { release, retain }.retain()writes aretainedmarker so a later acquirer fails fast withELOCKRETAINEDinstead of waiting out the 5-minute timeout — used when a build is cancelled mid-flight. Distinct error codes (ELOCKED,ELOCKRETAINED,ELOCKORPHANED,ECOMPROMISED,ERETAINFAILED) separate contention from corruption.Shared
getVenvPythonPath(src/common/utils/virtualEnvironment.ts, new): returnsScripts\python.exeon Windows, elsebin/python. Replaces an inline copy invenvUtilsand is reused by 5b/5c.Hardened process helper (
src/managers/builtin/helpers.ts):runUVandrunPythonnow share onerunProcessimplementation whose cancellation guardskill()intry/catchand still emits a cleanCancellationErrorif the process errors after a cancel. Per-caller options preserve existing behavior (collectStderr,logPrefix).venvUtils.ts:createWithProgressgainsCreateWithProgressOptions { trackUvEnvironment }, andCreateEnvironmentResultgainspkgInstallationCancelledso a caller can tell cancellation apart from a real install failure. Existing callers are unaffected (both are optional / additive).Tests
lockfile.apis.unit.test.ts— 9 tests: contention, retain/fail-fast, orphaned and compromised locks, and timeout.virtualEnvironment.unit.test.ts— 2 tests forgetVenvPythonPathon Windows and POSIX.helpers.cancellation.unit.test.ts— 4 tests forrunProcesscancellation safety.venvUtils.createWithProgress.unit.test.ts— 3 tests fortrackUvEnvironmentandpkgInstallationCancelled.On this branch alone
npm run compile-testsis clean andnpm run unittestreports 1447 passing, 0 failing, 4 pending.User impact
None. These are internal primitives with no new user-visible behavior. The refactors to
helpers.tsandvenvUtils.tsare behavior-preserving for existing callers.